import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from "axios"
import dataV from '@jiaminghi/data-view'
import echarts from 'echarts'
import './assets/css/index.css'
import './assets/iconfont/iconfont.css'


// 配置请求的根路径
axios.defaults.baseURL = '/api'
axios.defaults.withCredentials=true


// 挂载到原型对象之前 先设置拦截器 通过axios请求拦截器添加token，保证拥有获取数据的权限
// axios.interceptors.request.use(
//   config => {
//     config.headers['Content-Type'] = 'text/plain'
//     return config
//   }, err => {
//     return Promise.reject(err)
//   } 
// )

const app =createApp(App)
// 在app.use()之前设置axios原型对象
app.config.globalProperties.$axios = axios

app.config.globalProperties.$echarts = echarts

app.use(store).use(router).use(ElementPlus).use(dataV).mount('#app')
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }